package com.newgrand.annexserver.exception.handel;

import com.newgrand.annexcommon.utils.ResultUtil;
import com.newgrand.annexserver.exception.NoDataSourceException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 异常处理类
 *
 * @author ：minyang
 * @date ：Created in 2019/8/23 15:05
 */
@ControllerAdvice
public class CustomExtHandler {

    /**
     * 功能描述：无数据源异常
     *
     * @return
     */
    @ExceptionHandler(value = NoDataSourceException.class)
    @ResponseBody
    Object handleAuthException(NoDataSourceException e, HttpServletRequest request) {
        return ResultUtil.fail(e.getMsg());
    }

}
